﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:self="clr-namespace:VsxFactory.Modeling.StrategyManager.Dialog"
    xmlns:resources="clr-namespace:VsxFactory.Modeling.StrategyManager"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="TemplateStyles.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <self:BooleanToVisibilityConverter Inverted="True" x:Key="boolToVis" />
    <self:CountToVisibilityConverter x:Key="countConverter" />
    <self:CountToVisibilityConverter Inverted="True" x:Key="invertedCountConverter" />
    <BitmapImage x:Key="BitmapImage_AlreadyInstalled" UriSource="pack://application:,,,/Microsoft.VisualStudio.ExtensionManager.Implementation;Component/UI/AlreadyInstalled.png" />

    <!-- data template for the package extension item -->
    <DataTemplate x:Key="PackageItemTemplate">
        <Grid Style="{StaticResource TileTemplateGridStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="38" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Image Style="{StaticResource TileImageStyle}" Source="{Binding PackageIdentity.IconUrl, TargetNullValue={StaticResource BitmapImage_DefaultIcon}}" Width="32" Height="32" Stretch="Fill" StretchDirection="DownOnly">
            </Image>

            <StackPanel Grid.Column="1" Style="{StaticResource TileMiddleStackPanelStyle}">
                <StackPanel Orientation="Horizontal">
                <self:TextBlockControl  
                    Text="{Binding Name}" 
                    Style="{StaticResource TileTitleTextBoxStyle}">
                    <TextBlock.ToolTip>
                        <TextBlock Text="{Binding Name}" Style="{StaticResource TileToolTipStyle}"/>
                    </TextBlock.ToolTip>
                </self:TextBlockControl>
                    <self:TextBlockControl  Margin="5 0 0 0"
                    Text="{Binding Version}" 
                    Style="{StaticResource TileTitleTextBoxStyle}">
                        <TextBlock.ToolTip>
                            <TextBlock Text="{Binding Version}" Style="{StaticResource TileToolTipStyle}"/>
                        </TextBlock.ToolTip>
                    </self:TextBlockControl>
                </StackPanel>
                
                <self:TextBlockControl
                    Text="{Binding Description}" 
                    Style="{StaticResource TileDescriptionTextBoxStyle}">
                    <TextBlock.ToolTip>
                        <TextBlock Text="{Binding Description}" Style="{StaticResource TileToolTipStyle}"/>
                    </TextBlock.ToolTip>
                </self:TextBlockControl>
            </StackPanel>

            <StackPanel 
                Grid.Column="2"
                Style="{StaticResource TileRightStackPanelStyle}"
                Visibility="Visible">
                <Image
                    HorizontalAlignment="Right"
                    Source="{StaticResource BitmapImage_AlreadyInstalled}"
                    Visibility="{Binding IsEnabled, Mode=OneWay, Converter={StaticResource boolToVis}}">
                    <Image.ToolTip>
                        <TextBlock 
                            Text="{x:Static resources:Resources.Dialog_PackageInstalledTooltip}"
                            Style="{StaticResource TileToolTipStyle}"/>
                    </Image.ToolTip>
                </Image>
                <Button 
                    x:Name="ExecuteButton"
                    Command="{x:Static self:PackageManagerWindowCommands.PackageOperationCommand}"
                    Content="{Binding CommandName}"
                    IsDefault="True"
                    Visibility="Collapsed"
                    Style="{StaticResource DetailButtonStyle}" />
            </StackPanel>
        </Grid>

        <DataTemplate.Triggers>
            <MultiDataTrigger >
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding IsSelected}" Value="True" />
                    <Condition Binding="{Binding IsEnabled}" Value="True" />
                </MultiDataTrigger.Conditions>
                <Setter TargetName="ExecuteButton" Property="Visibility" Value="Visible" />
            </MultiDataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <!-- data template for the package details pane -->
    <DataTemplate x:Key="PackageDetailTemplate">
        <DataTemplate.Resources>
            <self:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
            <self:StringCollectionsToStringConverter x:Key="authorNamesConverter" />
        </DataTemplate.Resources>

        <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" Focusable="False">
            <StackPanel Margin="8">
                <!-- Authors -->
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <self:TextBlockControl Text="{x:Static resources:Resources.Dialog_CreatedByLabel}" Style="{StaticResource DetailMetadataLabelStyle}" />
                    <self:TextBlockControl Grid.Column="1" Text="{Binding Authors, Converter={StaticResource authorNamesConverter}}" Style="{StaticResource DetailMetadataValueStyle}" TextWrapping="Wrap" />
                </Grid>

                <!-- Version -->
                <StackPanel Style="{StaticResource DetailMetadataStyle}">
                    <self:TextBlockControl Text="{x:Static resources:Resources.Dialog_VersionLabel}" Style="{StaticResource DetailMetadataLabelStyle}" />
                    <self:TextBlockControl Text="{Binding Version}" Style="{StaticResource DetailMetadataValueStyle}"  />
                </StackPanel>

                <!-- View License link -->
                <TextBlock Visibility="{Binding LicenseUrl, Converter={StaticResource NullToVisibilityConverter}}">
                    <Hyperlink NavigateUri="{Binding LicenseUrl, Mode=OneTime}" Command="{x:Static self:PackageManagerWindowCommands.OpenExternalLink}">
                        <Run Text="{x:Static resources:Resources.License_ViewLicense}" />
                    </Hyperlink>
                </TextBlock>

                <!-- Project Url -->
                <TextBlock Visibility="{Binding PackageIdentity.ProjectUrl, Converter={StaticResource NullToVisibilityConverter}}">
                    <Hyperlink NavigateUri="{Binding PackageIdentity.ProjectUrl, Mode=OneTime}" Command="{x:Static self:PackageManagerWindowCommands.OpenExternalLink}">
                        <Run Text="{x:Static resources:Resources.Dialog_MoreInfo}" />
                    </Hyperlink>
                </TextBlock>

                <!-- Description -->
                <self:TextBlockControl Style="{StaticResource DetailDescriptionTextBoxStyle}" Text="{Binding Description}" >
                </self:TextBlockControl>

                <!-- Dependencies list -->
                <!--<self:TextBlockControl Text="{x:Static resources:Resources.Dialog_DependenciesLabel}" Style="{StaticResource DetailMetadataLabelStyle}" />

                <ItemsControl
                    x:Name="DependencyItems"
                    Margin="25,5,0,0"
                    ItemsSource="{Binding Dependencies}">
                </ItemsControl>

                <self:TextBlockControl 
                    x:Name="NoneLabel"
                    Margin="25,5,0,0"
                    Visibility="{Binding Items.Count, ElementName=DependencyItems, Converter={StaticResource invertedCountConverter}}"
                    Style="{StaticResource NoDependencyTextBoxStyle}" 
                    Text="{x:Static resources:Resources.Dialog_NoDependencyLabel}">
                </self:TextBlockControl>

                <self:TextBlockControl 
                    x:Name="Disclaimer"
                    FontStyle="Italic"
                    Visibility="{Binding Items.Count, ElementName=DependencyItems, Converter={StaticResource countConverter}}"
                    Style="{StaticResource DetailDescriptionTextBoxStyle}" 
                    Text="{x:Static resources:Resources.Dialog_PackageDisclaimer}"
                    TextWrapping="Wrap">
                </self:TextBlockControl>-->

            </StackPanel>
        </ScrollViewer>
    </DataTemplate>
</ResourceDictionary>

